package com.dhsc.service.impl.wdywgl;

import com.dhsc.domain.ywzx.wdywgl.H5ztcdVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.wdywgl.IH5ztcdDao;
import com.dhsc.service.wdywgl.IH5ztcdService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: H5ztcdController
 * @Description: h5掌厅菜单
 * @date: 2025/1/17 14:07
 * @author: jwj
 */
@Service
@Slf4j
public class H5ztcdServiceImpl implements IH5ztcdService {

    @Autowired
    private IH5ztcdDao h5ztcdDao;

    @Override
    public LayuiTableVo queryH5ztcd(H5ztcdVo h5ztcdVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            //导出标志位1的话，说明是导出excel发出的请求，不需要开启pageHelper
            if (h5ztcdVo.getExportFlag()!=1){
                PageMethod.startPage(h5ztcdVo.getPage(),h5ztcdVo.getLimit());
            }
            List<H5ztcdVo> list = h5ztcdDao.queryH5ztcd(h5ztcdVo);
            PageInfo<H5ztcdVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
            obj.setMsg("");
        }catch (Exception e){
            log.error("H5掌厅菜单查询异常",e);
            throw new MyException("H5掌厅菜单查询异常",e);
        }
        return obj;
    }
}
